

***************************************************************************************************
******************* Construction of the Regression dataset from the original dataset **************
***************************************************************************************************

//Import the following data file: Data_Covid_India_orig.dta. Then run this entire do file to get the data file: Data_Covid_India.dta

//Generate treatment dummies from categorical variable
table treat
tabulate treat, g(treat)
order treat1 treat2 treat3, after(treat)

//Generate log of monthly income
g log_inc=log(income)
summ log_inc
label variable log_inc "Log of monthly household income"
order log_inc , after(income)

//Generate caste categories
tabulate caste, g(caste_c)

//Generate dummy from employed variable, where 1=unemployment, 2=partially employed, 3=full-time employed
gen em=0  // 
replace em=1 if employed==2 | employed==3 
label variable em "=1 if employed and 0 if unemployed"


******************** Creation of the awareness dummies *************************
egen total_ans=rowtotal(wash_hands sneezing distance physical_contact healthy)
order total_ans, after(occupation)
label variable total_ans "Total number of correct responses (Awareness)"
table total_ans
g all_ans= total_ans==5
order total_ans all_ans, after(occupation)
label variable all_ans "Completely aware dummy"

******************** Creation of the compliance dummies ************************

g market3=0
replace market3=1 if market<=2
order market3, after(market)
label variable market3 "Going to the market dummy"

g doctor3=0
replace doctor3=1 if doctor<=2
order doctor3, after(doctor)
label variable doctor3 "Going to the doctor dummy"

g entertainment2=0
replace entertainment2=1 if entertainment<=2
order entertainment2, after( entertainment )
label variable entertainment2 "Going our for entertainment purpose dummy"
summ entertainment2

g religious2=0
replace religious2=1 if religious<=2
order religious2, after( religious)
label variable religious2 "Going out for religious purpose dummy"

g wash_practice2=0
replace wash_practice2=1 if wash_practice>2
summ wash_practice wash_practice2
order wash_practice2, after (wash_practice)
label variable wash_practice2 "Wash hands frequently dummy"

g hands_practice2=0
replace hands_practice2=1 if hands_practice>2
order hands_practice2, after(hands_practice)
label variable hands_practice2 "Avoided physical contact dummy"
//save "C:\Users\Debayan Pakrashi\Desktop\Extras Compliance\Final dataset\Data_Covid_India.dta"

//Generate the compliance index, so that the control group has mean 0 and SD 1
egen comply=rowtotal(market3 doctor3 entertainment2 religious2 wash_practice2 hands_practice2)
replace comply=comply/6
label variable comply "Compliance index (between 0 and 1)"

egen comp_control=mean(comply) if treat==1
replace comp_control = comp_control[_n-1] if comp_control >= .

egen comp_con_stdv=sd(comply) if treat==1
replace comp_con_stdv = comp_con_stdv[_n-1] if comp_con_stdv >= .

gen compidx=((comply-comp_control)/comp_con_stdv)
label variable compidx "Compliance index (standardized)"

drop comp_control comp_con_stdv

//Generate a revised compliance index (with two responses) for robustness check
egen comply_robust=rowtotal(wash_practice2 hands_practice2)
replace comply_robust=comply_robust/2
label variable comply_robust "Compliance index (0 to 1) using hand washing and contact only"

egen comp_control=mean(comply_robust) if treat==1
replace comp_control = comp_control[_n-1] if comp_control >= .

egen comp_con_stdv=sd(comply_robust) if treat==1
replace comp_con_stdv = comp_con_stdv[_n-1] if comp_con_stdv >= .

gen compidx_robust=((comply_robust-comp_control)/comp_con_stdv)
label variable compidx_robust "Compliance index (standardized) using hand washing and contact only"

drop comp_control comp_con_stdv comply_robust

